package com.itheima.sh.d_listener_04;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

//    1.实现接口的普通类 `
@WebListener
public class MyServletContextListener implements ServletContextListener {
//    2.重写抽象方法
    @Override
    public void contextInitialized(ServletContextEvent sce) {
//        启动tomcat时创建ServletContext对象
        System.out.println("对象被创建");

    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
//        关闭tomcat时
        System.out.println("对象被销毁");
    }
}
